<template>
  <user-content>
    <template v-slot:header>
      <span class="iconfont icon-kaoshi" style="color: #ed9420"></span>
      我的积分
    </template>
    <template v-slot:content>
      <p class="total-score">
        当前积分：<b>{{ totalScore }}</b>
      </p>

      <el-table :data="tableData" stripe style="width: 100%">
        <el-table-column prop="opt" label="类型">
          <template slot-scope="scope">
            <span>{{ scope.row.sysScoreRule.name }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="score" label="分数"> </el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="180">
        </el-table-column>
      </el-table>
      <Pagination
        v-show="parseInt(pageObj.count) > 0"
        :total="parseInt(pageObj.count)"
        @change="getList"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
      />
    </template>
  </user-content>
</template>
<script>
import {
  sysUserScoreQuery,
  sysUserScoreQueryUserScoreList,
} from '@/api/admin/system/sysScoreRule'
export default {
  data() {
    return {
      totalScore: 0,
      listQuery: {
        page: 1,
        limit: 10,
        userId: this.$store.getters.userId,
      },
      tableData: [],
      pageObj: {},
    }
  },
  mounted() {
    this.getList()
    this.getTotalScore()
  },
  methods: {
    getList() {
      sysUserScoreQuery(this.listQuery).then((res) => {
        this.tableData = res.data.data
        this.pageObj = res.data
      })
    },
    getTotalScore() {
      sysUserScoreQueryUserScoreList({
        userId: this.$store.getters.userId,
      }).then((res) => {
        this.totalScore = res.data.data[0].score
      })
    },
  },
}
</script>